package com.stars.empoly.adapter

import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.google.gson.Gson
import com.qmuiteam.qmui.kotlin.onClick
import com.stars.empoly.R
import com.stars.empoly.activity.*
import com.stars.empoly.databinding.ItemMsgBinding
import com.stars.empoly.model.TrMsgList
import com.stars.empoly.vmodel.MsgVModel
import com.trailer.base.base.BAdapter
import com.trailer.base.utils.B
import com.trailer.base.utils.UiSwitch

class MsgAdapter(var vm: MsgVModel) : BAdapter<TrMsgList, BaseDataBindingHolder<ItemMsgBinding>>(R.layout.item_msg) {

    override fun convert(holder: BaseDataBindingHolder<ItemMsgBinding>, item: TrMsgList) {
        holder.dataBinding?.vm = vm
        holder.dataBinding?.item = item
        holder.dataBinding?.position = holder.adapterPosition

        holder.dataBinding?.ll?.onClick {
            //消息详情
            UiSwitch.bundle(context(), MsgDetailsActivity::class.java,
                B().putString("index", ""+holder.adapterPosition)
                    .putString("bean", Gson().toJson(item)).ok(),)
        }


    }
}
